<?php /* Smarty version 2.6.18, created on 2015-09-02 13:18:02
         compiled from shellServerList.html */ ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "header.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "top.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "left.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>

<style>

 input[type=checkbox].ace, input[type=radio].ace {
opacity: 0;
position: absolute;
z-index: 12;
width: 18px;
height: 38px;
cursor: pointer;
}

.table-header {
background-color: #307ecc;
color: #FFF;
font-size: 14px;
line-height: 35px;
padding-left: 12px;
margin-bottom: 1px;
padding-bottom:2px;
}

.comments {  
 width:100%;/*自动适应父布局宽度*/  
 overflow:auto;  
 word-break:break-all; 
 border-color:#307ecc;
 float:left;
 }
</style>
<div class="main-content">
<div class="breadcrumbs" id="breadcrumbs"><script
	type="text/javascript">
	try {
		ace.settings.check('breadcrumbs', 'fixed')
	} catch (e) {
	}
</script>

<ul class="breadcrumb">
	<li><i class="icon-home home-icon"></i> <a
		href="index.php">首页</a></li>
</ul>
<!-- .breadcrumb --></div>

<div class="page-content">
<div class="col-xs-12">
<div class="alert alert-info">
<form class="form-horizontal" role="form">
<div class="row">

<div class="col-sm-1">
<div class="row">
<label class="col-sm-6 control-label no-padding-right" for="form-field-5">游戏</label>
<div class="col-sm-3"><select id="selectGame">
	<option value="" >游戏</option>
	<?php if ($this->_tpl_vars['selectGames']): ?> <?php $_from = $this->_tpl_vars['selectGames']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['value']):
?>
	<?php if ($this->_tpl_vars['nowGame'] == $this->_tpl_vars['value']): ?>
	<option value="<?php echo $this->_tpl_vars['value']; ?>
" selected><?php echo $this->_tpl_vars['value']; ?>
</option>
	<?php else: ?>
	<option value="<?php echo $this->_tpl_vars['value']; ?>
"><?php echo $this->_tpl_vars['value']; ?>
</option>
	<?php endif; ?> <?php endforeach; endif; unset($_from); ?> <?php endif; ?>
</select>
</div>
</div>
</div>



<div class="col-sm-2">
<div class="row">
<label class="col-sm-3 control-label no-padding-right" for="form-field-5">平台</label>
<div class="col-sm-3">
<select id="platform">
	<option value="" id="selectPlatform">平台</option>
	
	<?php if ($this->_tpl_vars['platforms']): ?> <?php $_from = $this->_tpl_vars['platforms']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['key'] => $this->_tpl_vars['value']):
?>
	<?php if ($this->_tpl_vars['platform'] == $this->_tpl_vars['value']): ?>
	<option value="<?php echo $this->_tpl_vars['value']; ?>
" selected><?php echo $this->_tpl_vars['value']; ?>
</option>
	<?php else: ?>
	<option value="<?php echo $this->_tpl_vars['value']; ?>
"><?php echo $this->_tpl_vars['value']; ?>
</option>
	<?php endif; ?> <?php endforeach; endif; unset($_from); ?> <?php endif; ?>
	
</select>
</div>
</div>
</div>



<div class="col-sm-3">
<div class="row">
<label class="col-sm-2 control-label no-padding-right" for="form-field-5">超时(ms)</label>
<div class="col-sm-9">
<input type="text" id="timeout" class="col-xs-6 col-sm-5" value ="<?php echo $this->_tpl_vars['timeout']; ?>
">
</div>
</div>
</div>



<div class="col-sm-2">
<div class="row"><label
	class="col-sm-3 control-label no-padding-right" for="form-field-5">&nbsp;&nbsp;&nbsp;&nbsp;</label>
<div class="col-sm-9">
</div>
</div>
</div>

</div>
</form>
</div>
</div>


<div class="col-xs-12">
<div class="table-header"> 
Shell命令   &nbsp;<button class="btn btn-primary" type="button" onClick="formSubmit();">执行Shell</button>  
<!-- 
<button class="btn btn-primary" type="button" onClick="formSubmitXML();">更新XML</button> 查看时间 date | 修改日期 date -s "<?php echo $this->_tpl_vars['nowTime']; ?>
" |  修改时间 date -s "<?php echo $this->_tpl_vars['Time']; ?>
" 
 -->

</div>
</div>
<form class="form-horizontal" role="form">
<label class="col-sm-3 control-label no-padding-right" for="form-field-5"></label>
<div class="col-sm-12">
<input style="border-color:#307ecc;" id="command" type="text" id="timeout" class="col-xs-12 col-sm-12" value ="<?php echo $this->_tpl_vars['command']; ?>
">
<!--  
<textarea  id="command" class="comments" rows=1   name=s1   cols=50   onpropertychange= "this.style.posHeight=this.scrollHeight" >
<?php echo $this->_tpl_vars['content']; ?>

</textarea>
-->
</div>

<!--  
<label class="col-sm-3 control-label no-padding-right" for="form-field-5"></label>
<label class="col-sm-3 control-label no-padding-right" for="form-field-5"></label>

<center>
<div class="col-sm-12">
<button type="button" onClick="formSubmit();"
	class="width-10 btn btn-sm btn-primary"><h5>执行</h5></button>
</div>
</center>
-->

</form>

<div class="col-xs-12">
<label class="col-sm-3 control-label no-padding-right" for="form-field-5"></label>
</div>


<div  class="col-xs-12">
<div  id ="servers2" class="table-header">
服务器列表
<?php if ($this->_tpl_vars['selectAll']): ?>
			<input style="padding-botton:10px;;"   name="checkbox3" type="checkbox" class="ace ace-checkbox-2" id="selectAll"   value="selectAll" /> 
			<label style="width:80px;" class="lbl" for="ace-settings-navbar">&nbsp;全选</label>
<?php endif; ?>
<?php if ($this->_tpl_vars['selectNo']): ?>
			<input  name="checkboxs2" type="checkbox" class="ace ace-checkbox-2" id="unSelect"   value="unSelect" />
			<label style="width:80px;" class="lbl" for="ace-settings-navbar">&nbsp;全不选</label>
<?php endif; ?>
</div>

<!-- style="width:100%;height:650px;overflow-x:auto;overflow-y:auto;" -->
<div  id="servers"  class="table-responsive">
<table id="sample-table-1"
	class="table table-striped table-bordered table-hover">
	<thead>
		<tr>
			<th>
				服务器
			</th>
			<th>主机地址</th>
			<th>db地址</th>
			<th>运行目录</th>
			<th>执行结果</th>
			<th>状态</th>
		</tr>
	</thead>
	<tbody>
	
		
		<?php $_from = $this->_tpl_vars['servers']; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); }if (count($_from)):
    foreach ($_from as $this->_tpl_vars['servers']):
?>
		<tr>
			<td   style="width:8%;padding-top:10px;"><input  name="checkboxs" type="checkbox" class="ace ace-checkbox-2" id="<?php echo $this->_tpl_vars['servers']['game']; ?>
" <?php if ($this->_tpl_vars['servers']['type'] == 0): ?> disabled="true" <?php endif; ?>   <?php if ($this->_tpl_vars['servers']['isView'] == 1): ?> checked<?php endif; ?> value = "<?php echo $this->_tpl_vars['servers']['name']; ?>
" />
				<label style="width:100px;" class="lbl" for="ace-settings-navbar">&nbsp;<?php echo $this->_tpl_vars['servers']['name']; ?>
</label>
			</td>
			<td  style="padding-top:20px;"><?php echo $this->_tpl_vars['servers']['ip']; ?>
:<?php echo $this->_tpl_vars['servers']['script_port']; ?>
</td>
			<td  style="padding-top:20px;"><?php echo $this->_tpl_vars['servers']['dburl']; ?>
</td>	
			<td  style="padding-top:20px;"><?php echo $this->_tpl_vars['servers']['folder']; ?>
</td>	
			<td style="width:70%;"> <textarea  class="comments" rows=1   name=s1   cols=50  onmouseover= "textCount(this,3);" onmouseout = "textCount(this,1)"><?php echo $this->_tpl_vars['servers']['res']; ?>

		</textarea>
			</td>
			<td align="center"  style="width:5%;padding-top:20px;"><?php echo $this->_tpl_vars['servers']['status']; ?>
</td>
		</tr>
		<?php endforeach; endif; unset($_from); ?>


	</tbody>
</table>
</div>
</div>



</div>
<!-- /.page-content --></div>
<!-- /.main-content -->
<script type="text/javascript">

function textCount(obj, value) {
	obj.rows  = value;
}	

//全选
$("#selectAll").click(function(){
	 $("#servers :checkbox").prop("checked", true); 
}); 
// 反选
$("#unSelect").click(function () {//全不选  
     $("#servers :checkbox").prop("checked", false); 
});  	
	
	jQuery(function($) {
		$('.date-picker').datepicker({
			autoclose : true
		}).next().on(ace.click_event, function() {
			$(this).prev().focus();
		});

		var oTable1 = $('#sample-table-2').dataTable({
			"aoColumns" : [ {
				"bSortable" : false
			}, {
				"bSortable" : false
			}, {
				"bSortable" : false
			}
			]
		});
		

	});

	function formSubmit() {
		var game = $('#selectGame').val();
		var platform = $('#platform').val();
		var timeout = $('#timeout').val();
		var command = $('#command').val();
		
		var servers=''; 
		$("input[name='checkboxs']:checked").each(function(){ 
			servers += $(this).val()+','; 
		});
		
		if (!game || !timeout || !command || !servers) {
			alert('请将信息填写完整！');
		} else {
			url = "index.php?mod=Shell&do=showServerList&game="+game+"&platform="+platform+"&servers="+servers+"&command="+command+"&timeout="+timeout;
			window.location.href = url;
		}

	}
	
	/*
	更新xml
	*/
	function formSubmitXML() {
		var game = $('#selectGame').val();
		var platform = $('#platform').val();
		var timeout = $('#timeout').val();
		
		var command = "sh /data/java/shell/upXml_" + game + ".sh";
		
		var servers=''; 
		$("input[name='checkboxs']:checked").each(function(){ 
			servers += $(this).val()+','; 
		});
		
		if  (!timeout || !servers) {
			alert('请选择服！');
		} else {
			url = "index.php?mod=Shell&do=showServerList&game="+game+"&platform="+platform+"&servers="+servers+"&command="+command+"&timeout="+timeout;
			window.location.href = url;
		}

	}
	
	
	window.onload = function(){
	    var select = document.getElementById('selectGame');
	    select.onchange = function(){
	    	
	        // 更改值后执行的代码
	       var gameName = jQuery("#selectGame  option:selected").text();
	       var game = $('#selectGame').val();
			url = "index.php?mod=Shell&do=showServerList&game="+game;
			window.location.href = url;  

	    }
	    // 选择平台
	    var selectPlatform = document.getElementById('platform');
	    selectPlatform.onchange = function(){
	    	
	        // 更改值后执行的代码
	        var platformName = jQuery("#platform  option:selected").text();
	        var game = $('#selectGame').val();
	        var platform = $('#platform').val();
			url = "index.php?mod=Shell&do=showServerList&game="+game+"&platform="+platform;
			window.location.href = url;  
	    }
	    
	} 
	
</script>
<?php $_smarty_tpl_vars = $this->_tpl_vars;
$this->_smarty_include(array('smarty_include_tpl_file' => "footer.html", 'smarty_include_vars' => array()));
$this->_tpl_vars = $_smarty_tpl_vars;
unset($_smarty_tpl_vars);
 ?>
